package rs.dalao.syc.index.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import rs.dalao.syc.index.dao.persist.repository.IEncRepository;
import rs.dalao.syc.index.dao.search.EncContentSearchRepository;
import rs.dalao.syc.index.pojo.vo.EncContentSearchVO;
import rs.dalao.syc.index.service.IEncContentSearchService;

import java.util.List;

@Service
public class EncContentSearchServiceImpl implements IEncContentSearchService {

    @Autowired
    private EncContentSearchRepository encContentSearchRepository;
    @Autowired
    private IEncRepository encRepository;
    //将从MySQL数据库中查询到的医学百科相关文章保存到Elasticsearch数据库中
    @Override
    public List<EncContentSearchVO> saveAll() {
        List<EncContentSearchVO> encContentSearchVOS = encRepository.selectAll();
        List<EncContentSearchVO> encContentSearchVOS1 =(List<EncContentSearchVO>) encContentSearchRepository.saveAll(encContentSearchVOS);
        return encContentSearchVOS1;
    }

    //从Elasticsearch中根据name,content,brief,title查询对应的内容
    @Override
    public List<EncContentSearchVO> customQuery(String title) {
        List<EncContentSearchVO> encContentSearchVOS = encContentSearchRepository.customQuery(title);
        return encContentSearchVOS;
    }
}
